package com.financing.platform.service.impl;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.financing.platform.dao.IFpProductDeepAnalyticsDao;
import com.financing.platform.dto.FpProductDeepAnalyticsDTO;
import com.financing.platform.dto.FpProductDeepAnalyticsHisDTO;
import com.financing.platform.service.IFpProductDeepAnalyticsService;

/**
 * @Description:Service实现类
 * @version 1.0
 * @created lisu
 */
 
@Service(value="fpProductDeepAnalyticsServiceImpl")
public class FpProductDeepAnalyticsServiceImpl implements IFpProductDeepAnalyticsService {
    @Autowired
	private IFpProductDeepAnalyticsDao fpProductDeepAnalyticsDaoImpl;

	@Override
	public FpProductDeepAnalyticsDTO getFpProductDeepAnalytics(
			FpProductDeepAnalyticsDTO dto) throws SQLException {
		return fpProductDeepAnalyticsDaoImpl.getFpProductDeepAnalytics(dto);
	}

	@Override
	public Integer saveFpProductDeepAnalyticsDTO(FpProductDeepAnalyticsDTO dto) throws SQLException{
		Integer saveCount = null;
		
		FpProductDeepAnalyticsDTO bean = new FpProductDeepAnalyticsDTO();
		bean.setFpProductId(dto.getFpProductId());
		bean = fpProductDeepAnalyticsDaoImpl.getFpProductDeepAnalytics(bean);
		
		if(bean == null ){
			saveCount = fpProductDeepAnalyticsDaoImpl.insertFpProductDeepAnalytics(dto);
		}
		else 
		{
			saveCount = fpProductDeepAnalyticsDaoImpl.updateFpProductDeepAnalytics(dto);
		
		}
		return saveCount;
	}
	@Override
	public Integer saveFpProductDeepAnalyticsHisDTO(FpProductDeepAnalyticsDTO dto) throws SQLException{
		
		FpProductDeepAnalyticsHisDTO productDeepAnalyticsHisDTO = new FpProductDeepAnalyticsHisDTO();
		productDeepAnalyticsHisDTO.setFpDeepAnalyticsHisId(dto.getId());
		productDeepAnalyticsHisDTO.setCreateBy(dto.getUpdateBy());
		productDeepAnalyticsHisDTO.setCreateDate(dto.getUpdateDate());
		productDeepAnalyticsHisDTO.setUpdateBy(dto.getUpdateBy());
		productDeepAnalyticsHisDTO.setUpdateDate(dto.getUpdateDate());
		productDeepAnalyticsHisDTO.setFpProductId(dto.getFpProductId());
		productDeepAnalyticsHisDTO.setFpProductFundsUse(dto.getFpProductFundsUse());
		productDeepAnalyticsHisDTO.setFpProductIssuers(dto.getFpProductIssuers());
		productDeepAnalyticsHisDTO.setFpProductLenders(dto.getFpProductLenders());
		productDeepAnalyticsHisDTO.setFpProductRelevantData(dto.getFpProductRelevantData());
		productDeepAnalyticsHisDTO.setFpProductRepaymentSource(dto.getFpProductRepaymentSource());
		productDeepAnalyticsHisDTO.setFpProductResume(dto.getFpProductResume());
		productDeepAnalyticsHisDTO.setFpProductRiskControl(dto.getFpProductRiskControl());
		productDeepAnalyticsHisDTO.setFpProductStatus(dto.getFpProductStatus());
		productDeepAnalyticsHisDTO.setFpProductStructureDiagram(dto.getFpProductStructureDiagram());
		return  fpProductDeepAnalyticsDaoImpl.insertFpProductDeepAnalyticsHis(productDeepAnalyticsHisDTO);
	}

}
